# -*- coding: utf-8 -*-
from django.shortcuts import render
from django.views.generic.base import View

from web.models import Category, Article


class CategoryView(View):
    def get(self, request):

        cate_list = Category.objects.all().order_by('id')
        article_list = []
        if cate_list:
            article_list = Article.objects.filter(category=cate_list[1]).all()

        context = {
            'cate_list': cate_list,
            'article_list': article_list,
            'is_show_paginator': True if len(article_list) < 10 else False
        }
        return render(request, 'category.html', context)
